#include "mainwindow.h"
#include <QMenuBar>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->resize(800,600);
    //菜单栏,获取当前窗口的菜单栏，没有就自动创建一个
    QMenuBar *mb = this->menuBar();
    //添加菜单
    QMenu *menuFile = mb->addMenu("文件");
    QMenu *menuEdit = mb->addMenu("编辑");
    //往菜单里添加菜单项
    QAction *actionNew = menuFile->addAction("新建");
    QAction *actionOpen = menuFile->addAction("打开");
    //添加分割符
    menuFile->addSeparator();

    //添加二级菜单
    QMenu *menuRecent = menuFile->addMenu("最近打开的文件");
    menuRecent->addAction("1.txt");
}

MainWindow::~MainWindow()
{
}

